import React, { useState } from 'react';
import { Select, Input, DatePicker, Space, Tag, Row, Col, message } from 'antd';
import AutoTable from '@/components/AutoTable';
const statusConf = {
    0: {
        text: '未开始',
        color: 'rgba(153, 153, 153,0.5)',
    },
    1: {
        text: '进行中',
        color: 'green',
    },
    2: {
        text: '已完成',
        color: '#3587C9',
    },
    3: {
        text: '已延期',
        color: '#ff4800',
    },
};
// 列配置
const columns = [
    {
        title: '项目名称',
        dataIndex: 'projectName',
        key: 'projectName',
    },
    {
        title: '状态',
        dataIndex: 'status',
        key: 'status',
        valueType: 'select',
        options: [
            { label: '未开始', value: 0 },
            { label: '进行中', value: 1 },
            { label: '已完成', value: 2 },
            { label: '已延期', value: 3 }
        ],
        render: (text, { status }) => {
            const color = status === 2 ? 'green' : 'volcano';
            return (
                <Tag  color={statusConf[status].color}  key={status}>
                    {text}
                </Tag>
            );
        },
    },
    {
        title: '消耗积木',
        dataIndex: 'block',
        key: 'block',
        sorter: (a, b) => a.block - b.block,
        search: false,
    },
    {
        title: '项目积分',
        dataIndex: 'points',
        key: 'points',
        sorter: (a, b) => a.points - b.points,
        search: false
    },
    {
        title: '参与人员',
        dataIndex: 'userNames',
        key: 'userNames',
        search: false,
        width:360,
        render: (text,record) => (record.userNames?.split('/')?.map(it=>(<Tag key={it}>{it}</Tag>)))
    },
    {
        title: '项目节点',
        dataIndex: 'projectNode',
        key: 'projectNode',
        search: false,
        render: (text,{finishItemCount,allItemCount}) => (
            <Space>
                {finishItemCount}/{allItemCount}
            </Space>
        ),
    },
    {
        title: '项目结束日期',
        dataIndex: 'deadline',
        key: 'deadline',
        search: false,
    },
];

const ProjectTable = ({ item }) => {
    return (
        <div style={{ marginBottom: 12 }}>
            <AutoTable
                headerTitle="项目列表"
                extraparams={{ orgId: item.id }}
                columns={columns}
                path={'/project/getProjectPage'}
                method='post'
                style={{ margin: "0 -12px" }} />
        </div>
    );
};

export default ProjectTable;
